package com.example.rbacmanage.service.impl;

import com.example.rbacmanage.entity.ChatJoin;
import com.example.rbacmanage.exception.MyException;
import com.example.rbacmanage.mapper.ChatJoinMapper;
import com.example.rbacmanage.service.ChatJoinService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 聊天接入服务实现类
 *
 * @author zmd
 */
@Service
public class ChatJoinServiceImpl  implements ChatJoinService {
    @Autowired
    private ChatJoinMapper  chatJoinMapper;

    @Override
    public void save(ChatJoin chatJoin) {
        chatJoin.setCreateTime(new Date());
        chatJoinMapper.insert(chatJoin);
    }

    @Override
    public void remove(Long[] ids) {
        for(Long id:ids){
                chatJoinMapper.del(id);
        }
    }

    @Override
    public void update(ChatJoin chatJoin) {
            chatJoinMapper.update(chatJoin);
    }

    @Override
    public List<ChatJoin> getAll(ChatJoin chatJoin) {
        return chatJoinMapper.list(chatJoin);
    }

    @Override
    public PageInfo<ChatJoin> getPage(ChatJoin chatJoin) {
        PageHelper.startPage(chatJoin.getPage(), chatJoin.getLimit());
        return new PageInfo<>(chatJoinMapper.list(chatJoin));
    }

    @Override
    public ChatJoin getById(Long id) {
        return chatJoinMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(ChatJoin chatJoin) {
        return chatJoinMapper.count(chatJoin);
    }

    @Override
    public void checkRepeat(ChatJoin chatJoin) throws MyException {

    }
}
